import 'package:inmotion_pro/l10n/local.dart';

enum ApiErrorType {
  /// 未知类型
  unknownType(-1),

  /// 请求成功
  success(20000),

  /// 未知错误
  unknownError(90000),

  /// 不支持的HTTP方法
  unsupportedMethod(40001),

  /// 路由未找到
  routeNotFound(40002),

  /// 请求过于频繁
  tooManyRequests(40003),

  /// 服务器错误
  serverError(50001),

  /// 参数必填
  paramsRequired(30001),

  /// 参数无效
  paramsInvalid(30002),

  /// 字段值不存在
  valueOfFiledDontExist(30003),

  /// token失效
  unauthenticatedRequest(30004),

  /// 暂无权限
  noPermission(30005),

  /// 重复操作
  duplicateOperation(30006),

  /// 未找到资源
  resourceNotFound(30007),

  /// 需要验证图形验证码
  verifyCaptcha(30008),

  /// 安全操作验证token无效
  invalidVerifyToken(30009),

  /// 未知的文件类型
  unknownFileType(30101),

  /// 未知的MIME类型
  unknownMimeType(30102),

  /// 超出分钟级限制
  rateLimitMinute(30111),

  /// 超出小时级限制
  rateLimitHour(30112),

  /// Email账号不存在
  emailAccountDoesntExist(30201),

  /// 用户名不存在
  nameAccountDoesntExist(30202),

  /// 手机号不存在
  phoneAccountDoesntExist(30203),

  /// Email账号已存在
  emailAccountAlreadyExist(30204),

  /// 手机号已存在
  phoneAccountAlreadyExist(30205),

  /// 密码错误
  pwdDoesntMatch(30211),

  /// 验证码错误
  verifyCodeDoesntMatch(30212),

  // 验证所需的token错误
  verifyTokenRequiredError(30213),

  /// 第三方账号未绑定乐行账号
  socialAccountUnknown(30221),

  /// 一键登录服务器异常
  phoneAuthServiceError(30222),

  /// 用户状态异常（被禁用）
  userBanned(30223),

  /// 此账号未设置密码
  pwdNotSet(30224),

  /// 授权失败
  authorizationFailed(30226),

  /// 关注失败
  userFollowFailed(30231),

  /// 取消关注失败
  userUnfollowFailed(30232),

  /// 自己关注/取消关注自己
  userFollowYourself(30233),

  /// 用户不存在
  userNotFound(30234),

  /// 收货信息超出最大记录数
  userDeliveryInfoOverCount(30235),

  /// 未知登录方式
  postTokenTypeUnknown(30291),

  /// 动态发布失败
  momentCreateFailed(30301),

  /// 动态删除失败
  momentDeleteFailed(30302),

  /// 点赞失败
  momentLikeFailed(30303),

  /// 取消点赞失败
  momentUnlikeFailed(30304),

  /// 评论失败
  momentCommentFailed(30305),

  /// 删除评论失败
  deleteCommentFailed(30306),

  /// 动态不存在或已删除
  momentNotFound(30307),

  /// 动态评论不存在或已删除
  momentCommentNotFound(30308),

  /// 未知产品型号
  productModelUnknown(30401),

  /// 未知事件
  productEventUnknown(30402),

  /// 主用户已存在
  productOwnerMainExisted(30403),

  /// token不存在或过期
  productOwnerInvalidToken(30404),

  /// 移除主用户时存在副用户
  productOwnerRemoveMainOwner(30405),

  /// 移除失败
  productOwnerRemoveFailed(30406),

  /// 主副用户转移失败
  productOwnerTransferFailed(30407),

  /// 申请已过期
  productOwnerRequestExpired(30408),

  /// 没有主用户
  productOwnerViceRequestNoMainOwner(30409),

  /// 超出最大认证用户数量
  productOwnerOverCount(30410),

  /// 已被管理员锁定
  productLockNoBizPermission(30411),

  /// 未知商品
  coinExchangeUnknownGoods(30501),

  /// 未知商品规格
  coinExchangeUnknownSpec(30502),

  /// 库存不足
  coinExchangeNoEnoughStock(30503),

  /// 积分不足
  coinExchangeNoEnoughCoin(30504),

  /// 购买失败-未知原因
  coinExchangeNewOrderFailed(30505),

  /// 不可兑换自己发布的商品
  coinExchangeHimself(30506),

  /// 超出当前商品规格最大可兑换数
  coinExchangeOverMaxTimes(30507);

  final int code;
  const ApiErrorType(this.code);

  /// 获取错误消息
  String get message {
    switch (this) {
      case ApiErrorType.unknownType:
        return "ApiErrorType - $code";
      case ApiErrorType.success:
        return local.successed;
      case ApiErrorType.unknownError:
        return local.unknown_error;
      case ApiErrorType.unsupportedMethod:
        return local.unsupported_method;
      case ApiErrorType.routeNotFound:
        return local.route_not_found;
      case ApiErrorType.tooManyRequests:
        return local.too_many_requests;
      case ApiErrorType.serverError:
        return local.server_error;
      case ApiErrorType.paramsRequired:
        return local.params_required;
      case ApiErrorType.paramsInvalid:
        return local.params_invalid;
      case ApiErrorType.valueOfFiledDontExist:
        return local.value_of_filed_dont_exist;
      case ApiErrorType.unauthenticatedRequest:
        return local.unauthenticated_request;
      case ApiErrorType.noPermission:
        return local.no_permission;
      case ApiErrorType.duplicateOperation:
        return local.duplicate_operation;
      case ApiErrorType.resourceNotFound:
        return local.resource_not_found;
      case ApiErrorType.verifyCaptcha:
        return local.verify_captcha;
      case ApiErrorType.invalidVerifyToken:
        return local.invalid_verify_token;
      case ApiErrorType.unknownFileType:
        return local.unknown_file_type;
      case ApiErrorType.unknownMimeType:
        return local.unknown_mime_type;
      case ApiErrorType.rateLimitMinute:
        return local.rate_limit_minute;
      case ApiErrorType.rateLimitHour:
        return local.rate_limit_hour;
      case ApiErrorType.emailAccountDoesntExist:
        return local.email_account_doesnt_exist;
      case ApiErrorType.nameAccountDoesntExist:
        return local.name_account_doesnt_exist;
      case ApiErrorType.phoneAccountDoesntExist:
        return local.phone_account_doesnt_exist;
      case ApiErrorType.emailAccountAlreadyExist:
        return local.email_account_already_exist;
      case ApiErrorType.phoneAccountAlreadyExist:
        return local.phone_account_already_exist;
      case ApiErrorType.pwdDoesntMatch:
        return local.pwd_doesnt_match;
      case ApiErrorType.verifyCodeDoesntMatch:
        return local.verify_code_doesnt_match;
      case ApiErrorType.verifyTokenRequiredError:
        return local.verify_token_required_error;
      case ApiErrorType.socialAccountUnknown:
        return local.social_account_unknown;
      case ApiErrorType.phoneAuthServiceError:
        return local.phone_auth_service_error;
      case ApiErrorType.userBanned:
        return local.user_banned;
      case ApiErrorType.pwdNotSet:
        return local.pwd_not_set;
      case ApiErrorType.authorizationFailed:
        return local.authorization_failed;
      case ApiErrorType.userFollowFailed:
        return local.user_follow_failed;
      case ApiErrorType.userUnfollowFailed:
        return local.user_unfollow_failed;
      case ApiErrorType.userFollowYourself:
        return local.user_follow_yourself;
      case ApiErrorType.userNotFound:
        return local.user_not_found;
      case ApiErrorType.userDeliveryInfoOverCount:
        return local.user_delivery_info_over_count;
      case ApiErrorType.postTokenTypeUnknown:
        return local.post_token_type_unknown;
      case ApiErrorType.momentCreateFailed:
        return local.moment_create_failed;
      case ApiErrorType.momentDeleteFailed:
        return local.moment_delete_failed;
      case ApiErrorType.momentLikeFailed:
        return local.moment_like_failed;
      case ApiErrorType.momentUnlikeFailed:
        return local.moment_unlike_failed;
      case ApiErrorType.momentCommentFailed:
        return local.moment_comment_failed;
      case ApiErrorType.deleteCommentFailed:
        return local.delete_comment_failed;
      case ApiErrorType.momentNotFound:
        return local.moment_not_found;
      case ApiErrorType.momentCommentNotFound:
        return local.moment_comment_not_found;
      case ApiErrorType.productModelUnknown:
        return local.product_model_unknown;
      case ApiErrorType.productEventUnknown:
        return local.product_event_unknown;
      case ApiErrorType.productOwnerMainExisted:
        return local.product_owner_main_existed;
      case ApiErrorType.productOwnerInvalidToken:
        return local.product_owner_invalid_token;
      case ApiErrorType.productOwnerRemoveMainOwner:
        return local.product_owner_remove_main_owner;
      case ApiErrorType.productOwnerRemoveFailed:
        return local.product_owner_remove_failed;
      case ApiErrorType.productOwnerTransferFailed:
        return local.product_owner_transfer_failed;
      case ApiErrorType.productOwnerRequestExpired:
        return local.product_owner_request_expired;
      case ApiErrorType.productOwnerViceRequestNoMainOwner:
        return local.product_owner_vice_request_no_main_owner;
      case ApiErrorType.productOwnerOverCount:
        return local.product_owner_over_count;
      case ApiErrorType.productLockNoBizPermission:
        return local.product_lock_no_biz_permission;
      case ApiErrorType.coinExchangeUnknownGoods:
        return local.coin_exchange_unknown_goods;
      case ApiErrorType.coinExchangeUnknownSpec:
        return local.coin_exchange_unknown_spec;
      case ApiErrorType.coinExchangeNoEnoughStock:
        return local.coin_exchange_no_enough_stock;
      case ApiErrorType.coinExchangeNoEnoughCoin:
        return local.coin_exchange_no_enough_coin;
      case ApiErrorType.coinExchangeNewOrderFailed:
        return local.coin_exchange_new_order_failed;
      case ApiErrorType.coinExchangeHimself:
        return local.coin_exchange_himself;
      case ApiErrorType.coinExchangeOverMaxTimes:
        return local.coin_exchange_over_max_times;
    }
  }
}
